<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<OBJECT id=MSComm1 CLASSID="clsid:648A5600-2C6E-101B-82B6-000000000014"
        codebase="MSCOMM32.OCX" type="application/x-oleobject">
    <PARAM   NAME="CommPort"   VALUE="2"/>
    <PARAM   NAME="DataBits"   VALUE="8"/>
    <PARAM   NAME="StopBits"   VALUE="1"/>
    <PARAM   NAME="BaudRate"   VALUE="9600"/>
    <PARAM   NAME="Settings"   VALUE="9600,N,8,1"/>

    <PARAM   NAME="RTSEnable"   VALUE="1"/>
    <PARAM   NAME="DTREnable"   VALUE="1"/>
    <PARAM   NAME="Handshaking"   VALUE="0"/>
    <PARAM   NAME="NullDiscard"   VALUE="0"/>
    <PARAM   NAME="ParityReplace"   VALUE="?"/>

    <PARAM   NAME="EOFEnable"   VALUE="0"/>
    <PARAM   NAME="InputMode"   VALUE="0"/>
    <PARAM   NAME="InBufferSize"   VALUE="1024"/>
    <PARAM   NAME="InputLen"   VALUE="0"/>
    <PARAM   NAME="OutBufferSize"   VALUE="512"/>

    <PARAM   NAME="SThreshold"   VALUE="0"/>
    <PARAM   NAME="RThreshold"   VALUE="1"/>

</OBJECT>
<script src="js/communication/ComPort.js" type="text/javascript"></script>
<script>
    var comPort;
    /**
     * 初始化控件
     */
    function initActiveX() {
        try{
            alert("aa");
            comPort = new ComPort();
            comPort.initActiveX("MSComm1");
            comPort.comNum = 2;
            comPort.open();
            alert("init success");
        }catch (e) {
            console.log(e);
            alert(e);
        }
    }
</script>
<body>
    <input type="button" onclick="initActiveX()" value="打开串口">
</body>
</html>